﻿@model Inscriptionem.Areas.Inscriptionem.Models.Views.MemberViewModel

@{
    ViewBag.Title = "Inscriptionem » Members » Add Member";
    Layout = "../Shared/Layout.cshtml";

    ViewBag.CurrentPage = "Members";

    string message = string.Empty;

    switch (Model.Error)
    {
        case Inscriptionem.Areas.Inscriptionem.Models.Enums.MemberError.FirstNameEmpty:
        {
            message = "Please enter First Name.";
            break;
        }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.MemberError.LastNameEmpty:
        {
            message = "Please enter Last Name.";
            break;
        }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.MemberError.MailEmpty:
        {
            message = "Please enter Mail.";
            break;
        }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.MemberError.MailNotValid:
        {
            message = "Please enter valid Mail.";
            break;
        }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.MemberError.MailNotAvailable:
        {
            message = "Mail address is in use by other member.";
            break;
        }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.MemberError.PasswordEmpty:
        {
            message = "Please enter Password.";
            break;
        }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.MemberError.PasswordNotMatch:
        {
            message = "Passwords does not match.";
            break;
        }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.MemberError.Other:
        {
            message = "Unknown error occurred, please try again.";
            break;
        }
    }

    var Roles = new Inscriptionem.ORM.DB().Roles.OrderBy(r => r.Name);
}

<link rel="stylesheet" href="/Content/Themes/jQueryUI/jquery-ui.min.css" />

<script src="/Content/Scripts/jQuery/jquery.min.js"></script>
<script src="/Content/Scripts/jQueryUI/jquery-ui.min.js"></script>
<script src="/Content/Scripts/jQueryUI/jquery.ui.datepicker.min.js"></script>

<div class="outer" id="contentwrap">
    @{Html.RenderPartial("NavigationMenu");}
    <div class="postcont">
		<div id="content">
            <div class="post type-post status-publish format-standard hentry">
                <h2 class="title">Add Member</h2>
                <div class="postdate-single error-message">@message</div>
                <hr />
                <form method="post" action="/Inscriptionem/Member/Add">
				    <div class="entry">
                        <p>First Name <input type="text" name="FirstName" value="@Model.FirstName" /></p>
                        <p>Nick Name <input type="text" name="NickName" value="@Model.NickName" /></p>
                        <p>Last Name <input type="text" name="LastName" value="@Model.LastName" /></p>

                        <p>Birth Date <input type="text" id="BirthDate" name="BirthDate" value="@(Model.BirthDate.HasValue ? Model.BirthDate.Value.ToShortDateString() : string.Empty)" /></p>
                        <p>Mail <input type="text" name="Mail" value="@Model.Mail" /></p>
                        <p>Password <input type="password" name="Password" value="" /></p>
                        <p>Confirm Password <input type="password" name="PasswordConfirmation" value="" /></p>

                        <p>Is Read-Only <input type="checkbox" name="IsReadOnly" @(Model.IsReadOnly ? "checked" : string.Empty) /></p>
                        <p>Is Approved <input type="checkbox" name="IsRegistrationApproved" @(Model.IsRegistrationApproved ? "checked" : string.Empty) /></p>
	                </div>
                    
                    <div class="postdate-single">Roles</div>
                    <div class="entry">
                    @{int iterator = 0;}
                    @foreach (var role in Roles)
                    { 
                        <text>
                        <fieldset style="border: none; margin: 0px; padding: 0px;">
                        <input type="hidden" name="Roles[@iterator].ID" value="@role.ID" />
                        <p>@role.Name <input type="checkbox" name="Roles[@iterator].Enabled" /></p>
                        </fieldset>
                        </text>
                        iterator++;
                    }
                    </div>

                    <input type="reset" value="Reset" />&nbsp;|&nbsp;<input type="submit" value="Add" />
                </form>
			</div>
        </div>
	</div>	
</div>

<script type="text/javascript">
    $(function () {
        $("#BirthDate").datepicker();
    });
</script>